#include<bits/stdc++.h>
using namespace std;

struct Node{
    char c;
    int cnt;
    Node* nex[26];
    Node():cnt{0}{memset(nex,0,sizeof(nex));}
    Node(char c_,int cnt_):c{c_},cnt{cnt_}{memset(nex,0,sizeof(nex));}
};

int n;
string s;

int main(){
    cin>>n;
    Node* root = new Node{};
    Node* cur;
    int mn = 0, ans=0;
    for(int i=1;i<=n;i++){
        mn = 0;
        cin>>s;
        cur = root;
        for(int j=0;s[j]!='\0';j++){
            if(cur->cnt!=0) mn=max(mn, cur->cnt);
            if(cur->nex[s[j]-'a']){
                cur = cur->nex[s[j]-'a'];
            }else{
                cur->nex[s[j]-'a'] = new Node{s[j],cur->cnt};
                cur = cur->nex[s[j]-'a'];
            }
        }
        cur->cnt = mn+1;
        ans = max(ans,mn+1);
    }
    cout<<ans<<"\n";
    return 0;
}